﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;

namespace TraceThisItem.Domain.Initializers
{
	public class CreateDatabaseAndSeedIfNotExists : CreateDatabaseIfNotExists<PersistenceManager>
	{
		protected override void Seed(PersistenceManager context)
		{
			#region Carga de Usuarios Demo

			var userPablo = new User
			{
				Firstname = "Pablo",
				Lastname = "Carballo",
				UserName = "pcarballo",
			};

			var userHernan = new User
			{
				Firstname = "Hernán",
				Lastname = "Zbucki",
				UserName = "hezbu",
			};

			context.Users.Add(userPablo);
			context.Users.Add(userHernan);

			#endregion Carga de Usuarios Demo

			#region Carga de Proyectos Demo

			var project1 = new Project
			{
				Name = "Forúnculo S.A.",
				OwnerUserName = "pcarballo",
				CreatedOn = DateTime.Now
			};

			var project2 = new Project
			{
				Name = "Proyecto MOSCA",
				OwnerUserName = "hezbu",
				CreatedOn = DateTime.Now
			};

			context.Projects.Add(project1);
			context.Projects.Add(project2);

			#endregion Carga de Proyectos Demo

			var team1 = new Team
			{
				Name = "Grosos"
			};

			team1.Users.Add(userHernan);
			team1.Users.Add(userPablo);

			project1.Teams.Add(team1);
			project2.Teams.Add(team1);

			#region Creacion de WorkFlows

			var workflow1 = new Workflow
			{
				Name = "Inicio"
			};
			#endregion

	
			var itemTypeBug1 = new ItemType
			{
				Name = "Bug",
				Project = project1,
				ProjectId = 1
			};


			var itemHz = new Item
			{
				CreatedOn = System.DateTime.Now,
				Description = "Mi incidencia",
				LatestUpdate = System.DateTime.Now,
				Priority = (byte)(ItemPriority.Baja),
				Project = project2,
				Team = team1,
				Type = itemTypeBug1
			};


		



			

		}
	}
}
